package com.learn.reflect;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.sql.SQLException;

/**
 * @author Created by chenxin34 on 2018/8/26 下午2:57.
 */
public class NoImplProxyTest {
    public static void main(String[] args) throws SQLException, ClassNotFoundException {
        Class<?> type = IService.class;
        IService proxy = (IService) Proxy.newProxyInstance(type.getClassLoader(), new Class[] {type}, new InvocationHandler() {
            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                System.out.println("before");
                return null;
            }
        });
        proxy.foo();
        boolean a = proxy instanceof IService;
        System.out.println(proxy.getClass().getName());
        System.out.println(a);

    }
}
